<html>
<head>
    <script language="javascript" type="text/jscript" src="datautil.js">
	</script>
    
    <script>
    	
/**
      = Hello Vocabulary @2010 =
	version 0.2.10
http://code.google.com/p/hello-vocabulary/
******************************************************

Copyright (c) 2010 Mead, laiqinyi@gmail.com


@ MIT License:Licensing
http://www.opensource.org/licenses/mit-license.php
@ Creative Commons License
http://creativecommons.org/licenses/by/2.5/legalcode
**/

chrome.extension.onRequest.addListener(
  function(request, sender, sendResponse) {
  	
   /* console.log(sender.tab ?
                "from a content script:" + sender.tab.url :
                "from the extension"+"##############################");*/
    if (request.word == "GW" && sender.tab){
	    	var turl = sender.tab.url;
	    	var list = getWords(turl).join(" ");
	    	//console.log("getWords List="+list);
	    	sendResponse({farewell: list});
    }else{    	
				var surl = JSON.parse(request.word);
				var date = new Date();
				//console.log("surl.title="+surl.title);
				if(surl.action=="A"){
		    		addWord(sender.tab.url,surl.word,surl.title,date.toLocaleDateString()); 
				}else if(surl.action=="D"){
					delWord(sender.tab.url,surl.word);
					//console.log("del surl.title="+surl.title);
				}
    		//DEBUG
  			//getAllURL();
      	//sendResponse({farewell: "Got Word____Add them"});    
    }
    
  	
  });

    </script>
</head>
<body></body>
</html>
